package com.chenjinyan.user.dao;

import com.chenjinyan.user.entity.LoginAccountEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;

/**
 * 保存用户登陆时间
 *
 * @author chenjinyan
 * @version 1.0
 */
@Repository
public interface UserLoginRepository extends JpaRepository<LoginAccountEntity, Long> {

    /**
     * 新增用户
     *
     * @param loginAccount 登陆账号
     */
    @Modifying
    @Query(value = "INSERT INTO lost_and_find_login_count(LOGIN_ACCOUNT,LOGIN_TIME) "
            + "VALUES(?1,NOW())", nativeQuery = true)
    @Transactional
    int inserLoginTime(String loginAccount);
}
